home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8330 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: news.dseg.ti.com!news    
  2. From: grubin@ti.com (Geoffrey Rubin)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Scope/longevity of class statics
  5. Date: 16 Feb 1996 20:55:17 GMT
  6. Organization: AWP
  7. Message-ID: <4g2qvl$3pr@mksrv1.dseg.ti.com>
  8. References: <4fu0qc$1h0@news.dcccd.edu> <4fvr6l$m1l@news.halcyon.com>
  9. NNTP-Posting-Host: cna0185662.dseg.ti.com
  10. Mime-Version: 1.0
  11. Content-Type: Text/Plain; charset=ISO-8859-1
  12. X-Newsreader: WinVN 0.99.5
  13.  
  14. In article <4fvr6l$m1l@news.halcyon.com>, normanb@halcyon.com says...
  15. >
  16. >bcalbridge@dcccd.edu (Bob Calbridge) wrote:
  17. >
  18. >>I know this sounds odd but since things didn't seem to work as
  19. >>expected I'll put the question to the newsgroup.  I have some
  20. >>class static data that represents an upper left corner offset
  21. >>for all display data.  In order to set the value I applied it
  22. >>to a temporary class object inside a function.  It seemed to
  23. >>work find for my purposes.  However, when I moved the code that
  24. >>set the values to another function that was invoked prior to the
  25. >>original function where it was instigated the values ended up
  26. >>improperly set by the time I got to my main code.  
  27. >
  28. Class static data still "belongs" to the class. If a temporary object
  29. is created of some class type inside the first function, it should not be
  30. accessed after that function has exited. When the function exits, the
  31. temporary goes out of scope and its destructor is called, and therefore
  32. its static data should not be considered valid.
  33.  
  34. Geoffrey
  35.  
  36.